﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using XRM.Security.DataAccess.Interfaces;

namespace XRM.Security.DataAccess.Models
{
    [Table("Request")]
    public class Request : IUserRegister
    {
        public Request()
        {
            RequestWorkKinds = new List<RequestWorkKind>();   
        }

        [Key]
        [DatabaseGeneratedAttribute(DatabaseGeneratedOption.Identity)]
        public int RequestId { get; set; }

        [Required]
        public int Number { get; set; }
        [Required]
        public DateTime CreateDate { get; set; }
        public DateTime? DeadLine { get; set; }
        public DateTime? CloseDate { get; set; }
        [Required]
        public int Status { get; set; }

        public string Comment { get; set; }

        [Required]
        public int UserRegisterId { get; set; }
        [Required]
        public int SystemUserId { get; set; }

        [ForeignKey("UserRegisterId")]
        public virtual UserRegister UserRegister { get; set; }
        [ForeignKey("SystemUserId")]
        public virtual SystemUser SystemUser { get; set; }
        
        public virtual ICollection<RequestWorkKind> RequestWorkKinds { get; set; }
    }
}